<?
include_once "_common.php";
include_once("config.php"); 
//************************************************************
//
// 스킨명 : 카멜레온 간이몰 스킨
// 버  젼 : 2006-03-16일짜 버젼
// 제작자 : ⓒⓒⓒ (Soonho Choi) http://cm-builder.com
// MSN    : oldccc@oldccc.com
// 
// 저작권 : 이 주석 부분을 훼손하지 상태에서 수정및 사용이 자유롭습니다.
//
//************************************************************
//
// 스킨명 : 간이몰 스킨 1v
// 수  정 : 2006-07-29일
// 수정자 : 스펙트럼 (toptalent) http://spectrum-enter.com/YBH/
// E-mail : top-talent@hanmail.net
// 
// 저작권 : 이 주석 부분을 훼손하지않은 상태에서 수정및 사용이 자유롭습니다.
//
//************************************************************

if($is_admin != 'super') alert("관리자만 접근이 가능합니다.");


include($shop['include_head']); 

$sql_common = " FROM {$g4[order_table]} a, {$g4[order_item_table]} b ";

$sql_search = " where a.od_id = b.od_id ";
if ($stx) {
    $sql_search .= " and ( ";
    switch ($sfl) {
        case "a.od_name" :
            $sql_search .= " ($sfl = '$stx') ";
            break;
        case "a.mb_id" :
            $sql_search .= " ($sfl = '$stx') ";
            break;
        default :
            $sql_search .= " ($sfl like '$stx%') ";
            break;
    }
    $sql_search .= " ) ";
}
if ($status) $sql_search .= "AND (a.od_status = '$status')";


// 2006-02-02 
if(!$fr_date) $fr_date = $g4[time_ymd];
if(!$to_date) $to_date = $g4[time_ymd];


if (!$sst) {
    $sst = "od_datetime";
    $sod = "desc";
}

$sql_order = " order by $sst $sod ";

$sql_group = "GROUP BY a.od_id ";

$sql = " select count(*) as cnt
         $sql_common
         $sql_search
         $sql_order ";
$row = sql_fetch($sql);
$total_count = $row[cnt];

$rows = $config[cf_page_rows];
$total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
if (!$page) $page = 1; // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함




$sql = " SELECT a.od_id, a.on_uid, a.mb_id, a.od_name, a.od_total_price, a.od_tel, a.od_hp, a.od_bank_use, a.od_bank_mb_name, a.od_status,			      a.od_bank_date, b.bo_table, b.wr_id, b.it_name, b.ca_name, a.od_datetime, count( b.od_qty ) od_cnt, b.od_price
          $sql_common
          $sql_search
  		  $sql_group 
          $sql_order
          limit $from_record, $rows ";
$result = sql_query($sql);

$qstr .= "&ext_search=$ext_search";
$qstr .= "&chk_1=$chk_1&chk_2=$chk_2&chk_3=$chk_3&chk_4=$chk_4";
$qstr .= "&s_1=$s_1&s_2=$s_2&s_3s=$s_3s&s_3e=$s_3e&s_4=$s_4";
$qstr .= "&fr_date=$fr_date&to_date=$to_date";
?>


<table width=100%>
<form name=fsearch method=get action='<?=$_SERVER[PHPSELP]?>'>
<input type=hidden name=status value='<?=$status?>'>
<input type=hidden name=page     value='<?=$page?>'>
<input type=hidden name=bo_table value='<?=$bo_table?>'>
<!--
<tr>
    <td colspan=2 align=right>
        <a onclick="chg_value(document.fsearch.status,'');" style='cursor:pointer;'>전체보기</a> <span class="small"><font color="#CCCCCC">|</font></span>
        <a onclick="chg_value(document.fsearch.status,'주문');" style='cursor:pointer;'>주문</a> <span class="small"><font color="#CCCCCC">|</font></span>
        <a onclick="chg_value(document.fsearch.status,'배송');" style='cursor:pointer;'>배송</a> <span class="small"><font color="#CCCCCC">|</font></span>
        <a onclick="chg_value(document.fsearch.status,'완료');" style='cursor:pointer;'>완료</a> <span class="small"><font color="#CCCCCC">|</font></span>
        <a onclick="chg_value(document.fsearch.status,'취소');" style='cursor:pointer;'>취소</a> <span class="small"><font color="#CCCCCC">|</font></span>
		<a onclick="chg_value(document.fsearch.status,'반품');" style='cursor:pointer;'>반품</a> <span class="small"><font color="#CCCCCC">|</font></span>
		<a onclick="chg_value(document.fsearch.status,'품절');" style='cursor:pointer;'>품절</a> <span class="small"><font color="#CCCCCC">|</font></span>
    </td>
</tr>
<tr>
    <td colspan=2 align=right>
        <input type=checkbox name=ext_search value='<?=$ext_search?>' <?=($ext_search)?"checked":"";?> onclick='chk_sw(this);togDis(ext_s,this.value);'>확장검색
    </td>
</tr>
<tr id=ext_s style='display:none'>
    <td colspan=2 align=right>
        <table width=300>
        <tr><td><input type=checkbox name=chk_1 value='1' <?=($chk_1)?"checked":"";?>></td>
            <td>기간검색 : </td>
            <td><input type=radio name=s_1 value='0' <?=(!$s_1)?'checked':''?> >가입일 
                <input type=radio name=s_1 value='1' <?=($s_1==1)?'checked':''?> >접속일 
            <br>
            <input type=text name=fr_date value='<?=$fr_date?>' onfocus="new CalendarFrame.Calendar(this)" size=10> - 
            <input type=text name=to_date value='<?=$to_date?>' onfocus="new CalendarFrame.Calendar(this)" size=10>
        </td></tr>
        <tr><td><input type=checkbox name=chk_2 value='1' <?=($chk_2)?"checked":"";?>></td>
            <td>성별검색 : </td>
            <td>
            <select name=s_2>
                <option value='M'>남자</option>
                <option value='F'>여자</option>
            </select>
        </td></tr>
        <tr><td><input type=checkbox name=chk_3 value='1' <?=($chk_3)?"checked":"";?>></td>
            <td>레벨검색 : </td>
            <td>
            <select name=s_3s>
                <? for($i=1;$i<=10;$i++) { ?>
                <option value='<?=$i?>'><?=$i?></option>
                <? } ?>    
            </select>
            <select name=s_3e>
                <? for($i=1;$i<=10;$i++) { ?>
                <option value='<?=$i?>'><?=$i?></option>
                <? } ?>    
            </select>
        </td></tr>
        <tr><td><input type=checkbox name=chk_4 value='1' <?=($chk_4)?"checked":"";?>></td>
            <td>지역검색 : </td>
            <td>
                <select name=s_4>
                    <option value='서울'>서울
                    <option value='부산'>부산
                    <option value='대구'>대구
                    <option value='인천'>인천
                    <option value='광주'>광주
                    <option value='대전'>대전
                    <option value='울산'>울산
                    <option value='강원'>강원
                    <option value='경기'>경기
                    <option value='경남'>경남
                    <option value='경북'>경북
                    <option value='전남'>전남
                    <option value='전북'>전북
                    <option value='제주'>제주
                    <option value='충남'>충남
                    <option value='충북'>충북
                </select>
        </table>
    </td>
    <script language="JavaScript">

        function chk_sw(f)
        {

            if(f.checked) f.value = 1;
            else        f.value = 0;
        }

        function chg_value(chg_name,chg_value)
        {
            chg_name.value = chg_value;
            document.fsearch.submit();
        }

        function togDis(el,chk) { 

            if (chk == '1') el.style.display = 'block'; 
            else            el.style.display = 'none';
        }

        function search(f)
        {
            f.onsubmit = '';
            f.submit();

        }
       
        
        var f = document.fsearch;
        f.s_2.value='<?=$s_2?>';
        f.s_3s.value='<?=$s_3s?>';
        f.s_3e.value='<?=$s_3e?>';
        f.s_4.value='<?=$s_4?>'; 

        //togDis(ext_s,f.ext_search.value);

    </script>
</tr>
-->
<tr>
	<td width=50% align=left>
	<a onclick="chg_value(document.fsearch.status,'');" style='cursor:pointer;'>전체</a> <span class="small"><font color="#CCCCCC"> | </font></span> 
	<a onclick="chg_value(document.fsearch.status,'주문');" style='cursor:pointer;'>주문</a> <span class="small"><font color="#CCCCCC"> | </font></span> 
	<a onclick="chg_value(document.fsearch.status,'배송');" style='cursor:pointer;'>배송</a> <span class="small"><font color="#CCCCCC"> | </font></span> 
	<a onclick="chg_value(document.fsearch.status,'완료');" style='cursor:pointer;'>완료</a> <span class="small"><font color="#CCCCCC"> | </font></span> 
	<a onclick="chg_value(document.fsearch.status,'취소');" style='cursor:pointer;'>취소</a> <span class="small"><font color="#CCCCCC"> | </font></span> 
	<a onclick="chg_value(document.fsearch.status,'반품');" style='cursor:pointer;'>반품</a> <span class="small"><font color="#CCCCCC"> | </font></span> 
	<a onclick="chg_value(document.fsearch.status,'품절');" style='cursor:pointer;'>품절</a>
	</td>
	<td width=50% align=right>
	<select name=sfl class=cssfl>
		<option value='a.mb_id'>회원아이디</option>
		<option value='a.od_name'>이름</option>
	</select>
	<input type=text name=stx  itemname='검색어' value='<? echo $stx ?>'>
	<input type=image src='<?=$g4[admin_path]?>/img/btn_search.gif' align=absmiddle>
	</td>
</tr>
</form>
</table>

<style>
.l_t_line   { background-color: #CCCCCC; height:2px;}    /* 타이틀 상단 라인 */
.l_t_bg     { background-color: #F9F9F9; height:34px;}        /* 리스트 타이틀 배경색 */    
.l_t_text   { cursor:pointer;color:#B9B9B9;text-decoration:none;font-size:9pt;width:100%;font-family:돋움;filter:dropshadow(color=#303030,offX=1,offY=1,positive=1);}
.l_t_line2  { background-color: #CCCCCC; height:1px;}    /* 타이틀 하단 라인 */
</style>


<table width=100% cellpadding=0 cellspacing=0 border=0>
<form name="orderlist" method="post">
<input type="hidden" name="bo_table" value="<?=$bo_table?>">
<input type="hidden" name="status" value=<?=$status?>>
<input type="hidden" name="sfl"  value="<?=$sfl?>">
<input type="hidden" name="stx"  value="<?=$stx?>">
<input type="hidden" name="spt"  value="<?=$spt?>">
<input type="hidden" name="page" value="<?=$page?>">
<input type="hidden" name="sw"   value="">
<tr><td colspan=10 class=l_t_line></td></tr>

<tr class="l_t_bg" align="center">
	<td><INPUT onclick="if (this.checked) all_checked(true); else all_checked(false);" type=checkbox></td>
	<td>번호</td>
	<td>성명</td>
	<td>연락처</td>
	<td>구매상품</td>
	<td>수량</td>
	<td>주문합계</td>
	<td>주문일자</td>
	<td>상태</td>
	<td>상세보기</td>
</tr>
<tr><td colspan=10 class=l_t_line2></td></tr>
<? for($i=1;$row=sql_fetch_array($result);$i++) { ?>
<tr align="center">
	<td height="25"><input type=checkbox name=chk_od_id[] value='<?=$row[od_id]?>'></td>
	<td class="small"><a href="#1" onClick="order_view('<?=$row[od_id]?>')"><?=$row[od_id]?></A></td>
	<td class="small"><?=$row[od_name]?></td>
	<td class="small"><?=$row[od_tel] == '' ? $row[od_tel] : $row[od_hp] ?></td>
	<td class="small"><?=$row[it_name]?> <?=$row[od_cnt] > 1 ? "외" : ""?> </td>
	<td class="small"><?=$row[od_cnt]?>&nbsp;</td>
	<td class="small"><?=number_format($row[od_total_price])?></td>
	<td class="small"><?=substr($row[od_datetime],2,8)?></td>
	<td class="small"><?=$row[od_status]?></td>
	<td class="small"><a href="#1" onClick="order_view('<?=$row[od_id]?>')"><img src="<?=$board_skin_path?>/img/order_view.gif" border="0"></a></td>
</tr>
<tr><td colspan="10" height="1" background="./img/dot.gif"></td></tr>
<? } ?>
</table>

<table width=100% height="36">
<tr>
    <td align=left >
        <input type=radio name=od_status value='쇼핑'>쇼핑 
        <input type=radio name=od_status value='주문' checked>주문 
        <input type=radio name=od_status value='배송'>배송 
		<input type=radio name=od_status value='완료'>완료 
		<input type=radio name=od_status value='취소'>취소 
		<input type=radio name=od_status value='반품'>반품 
        <input type=radio name=od_status value='품절'>품절
    </td>
</tr>
<tr>
    <td>
        <input type=button value='상태처리' onclick="check_confirm();">
    </td>
</tr>
</form>
</table>
<center><a href='./orderlist.php?bo_table=<?=$bo_table?>'><img src='./img/btn_list.gif' border=0></a></center>



<script language="JavaScript">
function all_checked(sw)
{
    var f = document.orderlist;

    for (var i=0; i<f.length; i++) {    
        if (f.elements[i].name == "chk_od_id[]")
            f.elements[i].checked = sw;
    }
}

function order_view(od_id)
{
    var url = './orderview.php?bo_table='+g4_bo_table+'&od_id='+od_id;
    var opt = 'scrollbars=yes,width=600,height=500,top=10,left=20';
    popup_window(url, 'orderview', opt);

}


function check_confirm()
{
    var f = document.orderlist;
    var chk_count = 0;

    for (var i=0; i<f.length; i++) {
        if (f.elements[i].name == "chk_od_id[]" && f.elements[i].checked)
            chk_count++;
    }



    if (!chk_count) {
        alert("처리할 게시물을 하나 이상 선택하세요.");
        return false;
    }

    f.action = "./orderlist_u.php";
    f.submit();

}


</script>

<?
include_once($shop['include_tail']); 
?>
